#pragma once

#include "PackageableElement.h"


namespace uml {

PackageableElement::PackageableElement(const QString& umlType)
    : NamedElement(umlType) {}

void PackageableElement::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    ParameterableElement::fromJson(json, errorList);
    NamedElement::fromJson(json, errorList);
    visibility_ = (VisibilityKind)json.value("visibility").toInt((int)visibility_);
}

void PackageableElement::toJson(QJsonObject& json) {
    ParameterableElement::toJson(json);
    NamedElement::toJson(json);
    json.insert("visibility", (int)visibility_);
}

/// <summary>
/// visibility getter
/// A PackageableElement must have a visibility specified if it is owned by a
/// Namespace. The default visibility is public.
/// </summary>
VisibilityKind PackageableElement::visibility() const {
    return visibility_;
}

/// <summary>
/// visibility setter
/// A PackageableElement must have a visibility specified if it is owned by a
/// Namespace. The default visibility is public.
/// </summary>
void PackageableElement::setVisibility(VisibilityKind value) {
    visibility_ = value;
}

} // namespace uml
